Skip to content

feat: clearer messages when an api call is refused or held back - #9576

Merged
koenvanderveen merged 7 commits into
devfrom
atlaie/policy-ux-messages
Nov 23, 2026
Merged

koenvanderveen merged 7 commits into
devfrom
atlaie/policy-ux-messages

Conversation

@atlaie

@atlaie atlaie commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Found while testing #9566 end to end in Colab. This PR only changes messages and displays; no behaviour changes.

  • When a blocking api call finishes, SyftRDSClient._wait_for_call() previously printed only the job status. Now it calls client.py: _print_call_result(), which also prints the refusal reason, or that the outputs were held back.
  • When someone other than the DO reads job.stdout or job.stderr and has no copy of that log, we previously showed "No stdout file found". Now we say the log is not shared with them, and how it can be shared: share_job_results for a normal job, request_stdout or request_stderr for an enclave job (EnclaveJobInfo._log_release_hint()). When a policy refused the call, we point to job.policy_error instead. The DO still sees "No stdout file found".
  • When a DS lists the apis, the table (HTML and text) previously did not show which policies an api has. Now it has a Policies column: input, output, input, output or -.
  • When the DO creates an api or calls set_policies, the returned ApiResult previously did not list the api's arguments or say whether the api's state was cleared. Now it lists the arguments, and says when set_policies cleared the state (reset_state=True, the default). print(result) previously printed the raw pydantic fields; now it shows the same text as repr(result).
  • When the DO opens a job in a notebook, the job view previously did not show the job's parameters. Now it has a Parameters section with code/params.json, pretty-printed and HTML-escaped.

Guidelines

High level

  • 🟢 Split: all changes are messages or displays for api calls under a policy, found in one Colab test
  • 🟢 Size: clearer messages and displays when a policy refuses an api call or holds its outputs back

Mid level

  • 🟢 User-facing code
  • 🟢 Error handling
  • 🟢 State versioning: ApiResult.args and ApiResult.state_cleared are returned to the caller, not stored
  • 🟠 Function structure: job_repr.py: _params_html() returns "" when there is no code/params.json, so the caller cannot see the condition
  • 🟢 Tests

Low level

  • 🟢 Naming
  • 🟢 Code style

Security

No change to permissions. The new messages tell the DS that a log is not shared and how it can be shared; they do not share it. The Parameters section HTML-escapes code/params.json, which the DS writes, so it cannot inject HTML into the DO's notebook.

Testing

  • Ran uv sync --all-packages, just test-unit-job (157 passed), just test-unit-rds (155 passed), uv run pytest tests/unit/syft_bg (174 passed) and pre-commit run --all-files (passes).
  • New tests, which fail on dev:
    • packages/syft-rds/tests/test_api_policies.py: capsys checks for the output-policy and rate-limit refusals, a held-back outputs test, and a Policies column test.
    • tests/unit/syft_bg/test_api_result.py: the args, the cleared state, and print(result).
    • packages/syft-job/tests/test_policies.py: the "not shared with you" log message, and the escaped Parameters section.
    • packages/syft-enclave/tests/test_read_permissions.py: an enclave job's unshared log points to request_stdout / request_stderr.
  • tests/integration/syft_bg/test_cli.py gives 24 passed and 2 failed. The 2 remove-peer failures happen the same way on dev without this change (the test sets up an api without run.sh), so I left them alone.

Asana task

- output_paths points to job.policy_error when a policy refused the call,
  and says when the output policy held the outputs back
- a blocking api call prints why it ended (_print_call_result)
- the api table has a Policies column
- ApiResult shows the api's args and when set_policies cleared its state;
  print(result) shows the same text as repr
- the job view shows code/params.json in a Parameters section

Messages and displays only; no behaviour changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@atlaie
atlaie force-pushed the atlaie/policy-ux-messages branch from 0a5d306 to f6b3ebf Compare November 13, 2026 13:14
job.stderr, job.stdout and the hint of a failed job's output_paths said
"No stderr file found" or "Check stderr" to a reader who was never given
the log. They now say it is not shared with them, and who can share it:
share_job_results for a datasite job, request_stderr / request_stdout
for an enclave job. A call that a policy refused points to
job.policy_error, since the log may not exist. The datasite owner, who
keeps every log, still sees "No stderr file found".

Messages only; no behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
output_paths is a user-facing API that is also used for chaining, so it
should not print much. The new branches also mixed low-level checks into
it. Drop the test checks on what it prints.
@koenvanderveen

Copy link
Copy Markdown
Collaborator

Thanks for this! I reverted the changes to JobInfo.output_paths in 2edaf96, and removed the test checks on what it prints. Two reasons:

  • output_paths is a user-facing API that can also be used for chaining, so it should not print too much.
  • The new branches mix too much low-level logic (checking policy_error, whether stderr.txt exists, and outputs_withheld) into a high-level method whose job is to return the output files.

The rest of the PR stays as it was, including _print_call_result() after a blocking api call and the new job.stdout / job.stderr messages.

test_api_policies_allow_block_and_show checked the api view, the call as a
request, the output policy and the rate limit in one run, with the rate
limit relying on the earlier call. Each is now its own test on a fresh api
from the new _adder_api() helper, which test_held_back_outputs_point_to_the_policy
also uses. Variables say what they hold (blocked_job, large_call).
Drop filler words from test names and give vague names a noun, e.g.
test_print_shows_the_summary -> test_api_result_str_matches_repr and
ok -> ok_result.

@koenvanderveen koenvanderveen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@koenvanderveen
koenvanderveen merged commit fb61754 into dev Nov 23, 2026
22 checks passed
@koenvanderveen
koenvanderveen deleted the atlaie/policy-ux-messages branch November 23, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants